home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 128 29
/
q29.d81
/
t.st demo
< prev
next >
Wrap
Text File
|
2022-08-28
|
17KB
|
353 lines
S T E P T R A C E R
Program and Text by e. g. bell
FENDER'S PREMUMBLE: StepTracer is a programmer's utility and is not
designed to be something you can access from LOADSTAR 128's menu. However,
ed has provided a revised version of CONTROL80's demo, which shows you that
StepTracer works with CONTROL80 programs -- at least on a C-128D. I
couldn't get it to work right on a flat C-128, so I don't recommend looking
at the demo on a flat C-128 unless you like a blank screen half way through
the demo. My theory is that CONTROL80's VLOAD command is a little too
weird for StepTracer. It's also hardcoded for drive 8. I don't consider
VSAVE and VLOAD to be among CONTROL80's more useful commands so you should
still be able to use StepTracer with your CONTROL80 programs. Even on a
C-128D there is a spot at the end of the demo where it asks you to press a
key while the screen scrolls horizontally. Press RESTORE instead and you
get back to the demo's title screen where you can return to LOADSTAR 128.
*** StepTracer
When debugging a BASIC program, it is often necessary to follow the
flow of logic. When you get unexpected results, is the program doing what
you want it to do or is it just doing what you told it to do? There are
several utilities of varying degrees of usefulness in determining this.
*** Dump
There are 'dump' utilities which dump the names and current values of
all variables. Using such a utility usually requires frequent STOPs to
check these values at various points in the program operation.
This can be useful in determining why or where something is happening
in a program, but a computer executes a program at an extremely high rate
of speed. Couple that with the many twists and turns the program can take
while getting from here to there and it can be a long, time-consuming
process to isolate and fix some problems using only a dump utility.
*** Follow Me
More useful are the 'trace' utilities. Most of these trace program
flow by printing the line number, to the screen inside brackets, of the
BASIC statement currently being executed. For example, consider the
following code:
10 print chr$(147):na$="":cnt=0:input "Enter Name ";na$
If you used the BASIC 7.0 TRON command, it would produce the following
screen display:
[10][10][10][10]Enter Name ?
If you have never tried this with your Commodore 128 BASIC programs, type
TRON then run any BASIC program. [TROFF toggles this function off.]
There have been many such utilities published for the C64 over the
years also. Most, if not all of these, function exactly the same. As
helpful as this type of utility is, as you may have noticed from the
example, there are some serious limitations.
*** Drawbacks
First, using this type of trace, screen display is hopelessly disrupted
as rows and rows of line numbers are dutifully displayed onscreen starting
wherever the cursor happened to be resting at the time. There is much
information presented, but it is confusing if you can use it at all. This
is particularly true in the case of deeply nested loops or GOSUB/GOTO
procedures. The information can be simply overwhelming.
Second, often you know where something is happening, but cannot locate
where the offending code is being called. This can be particularly
troublesome to find if the code is called from several places. Which call
is causing the problem? StepTracer will help you isolate such calls
quickly. This capability of StepTracer will help you find and correct the
problem areas instead of wasting a lot of time looking at the wrong place
in your code.
Third, the trace, like the program being traced, is operating at
extreme speeds. It is virtually impossible to visually follow the
execution unless frequently stopped by user input or STOP statements. This
can be irritating and confusing. If sections of the code being traced
clear the screen, it can be quite impossible. If you STOP the program, you
must start it again with a GOTO, CONT, or RUN. If you merely request user
input, the screen display problem mentioned above presents itself,
particularly if you are trying to find out why something is being displayed
WHERE it is being displayed.
Finally, you learn little from only a line number unless you are
working with a program listing in front of you, especially when a problem
involves several lines or routines. Since you are usually the person who
wrote the program, it is your logic. If the logic in the listing was
working as expected, you wouldn't need to trace the flow. In addition, if
the program flow jumps around a lot, with GOSUBs for example, it can become
difficult to follow the logical flow from a listing alone. So a listing by
itself is often of limited help in battling some bugs.
*** A Solution
There is a solution. StepTracer is a short single-step trace routine
for the Commodore 128 in 80 column mode. It will not work in 40 column
mode. StepTracer will lead you along the precise route your program is
taking. But it does more!
More than just the line numbers, the complete segment of BASIC code TO
BE EXECUTED is displayed for you prior to its execution. You know what
will take place and in which line it was commanded to do so just BEFORE it
actually happens.
If that is not enough, there is virtually no disruption of screen
display. Using some interesting capabilities of the VDC chip in your
Commodore 128, StepTracer gives you some extra lines at the bottom of your
screen IN ADDITION TO the normal 25 lines. But it does still more.
*** Single Step
Even displaying a segment of code would be of minimal value if it
happened at extreme speed, so StepTracer is an adjustable speed trace
utility AND a single-stepper. You may slog through your code at various
speeds OR step through your program one segment at a time if you like.
In single-step mode, after the program segment is displayed, you must
press a SHIFT Key to continue. (In single-step mode, a '*' is displayed
after the line number and before the program text to flag that user input
is expected before the program can continue) When you do, the segment of
code you are looking at is executed and the next segment is displayed. If,
for example, the current segment says GOTO 50 the next thing you will see
in the trace window is the first code segment of line 50. This feature
could also be helpful to novice computer programmers wondering what
different segments of someone else's code do.
In single-step mode, if you want to stop the program for editing, you
must press the STOP key and then press the SHIFT key to resume execution.
The program will then stop normally.
Note that I refer to code 'segments' above rather than just 'lines'.
This is because BASIC evaluates lines of code in this manner when there are
multiple commands on a single line. In cases like this, StepTracer lists
each such command individually, just as BASIC will execute it. The line
number remains onscreen though, so regardless of which segment is being
displayed, the appropriate line number is always evident.
*** Tron
Using StepTracer is very simple and will interfere with no BASIC
programs. First, you must install it using the BLOAD command:
bload "StepTracer"
Next, you simply activate it:
sys 2816,a,b
a = 0-Trace Disabled 1-Trace Enabled
b = 0-6 Speed of trace display 0-fastest 6-slowest
or b = 128 Requires pressing SHIFT after each segment displayed
So, to turn the trace on with a speed factor of 3, the command would be:
sys 2816,1,3
To turn the trace on with a speed factor of 0, the fastest possible, the
command would be:
sys 2816,1,0
To turn the trace on and specify that you must press the SHIFT key after
each segment is displayed, the command would be:
sys 2816,1,128
If you just want to toggle trace mode on with the current speed setting
unchanged, you may use the BASIC 7.0 'TRON' command in your BASIC program.
StepTracer recognizes this command as its own and resumes the trace. For
this reason, the normal function